﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title></title>

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/assets/materialize/css/materialize.min.css"
	media="screen,projection" />
<!-- Bootstrap Styles-->
<link href="${pageContext.request.contextPath}/assets/css/bootstrap.css"
	rel="stylesheet" />
<!-- FontAwesome Styles-->
<link
	href="${pageContext.request.contextPath}/assets/css/font-awesome.css"
	rel="stylesheet" />
<!-- Morris Chart Styles-->
<link
	href="${pageContext.request.contextPath}/assets/js/morris/morris-0.4.3.min.css"
	rel="stylesheet" />
<!-- Custom Styles-->
<link
	href="${pageContext.request.contextPath}/assets/css/custom-styles.css"
	rel="stylesheet" />
<!-- Google Fonts-->

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/assets/js/Lightweight-Chart/cssCharts.css">
<!-- JS Scripts-->


<!-- jQuery Js -->
<script
	src="${pageContext.request.contextPath}/assets/js/jquery-1.10.2.js"></script>

<!-- Bootstrap Js -->
<script
	src="${pageContext.request.contextPath}/assets/js/bootstrap.min.js"></script>

<script
	src="${pageContext.request.contextPath}/assets/materialize/js/materialize.min.js"></script>

<!-- Metis Menu Js -->
<script
	src="${pageContext.request.contextPath}/assets/js/jquery.metisMenu.js"></script>
<!-- Morris Chart Js -->
<script
	src="${pageContext.request.contextPath}/assets/js/morris/raphael-2.1.0.min.js"></script>
<script
	src="${pageContext.request.contextPath}/assets/js/morris/morris.js"></script>


<script
	src="${pageContext.request.contextPath}/assets/js/easypiechart.js"></script>
<script
	src="${pageContext.request.contextPath}/assets/js/easypiechart-data.js"></script>

<script
	src="${pageContext.request.contextPath}/assets/js/Lightweight-Chart/jquery.chart.js"></script>
<!-- DATA TABLE SCRIPTS -->
<script
	src="${pageContext.request.contextPath}/assets/js/dataTables/jquery.dataTables.js"></script>
<script
	src="${pageContext.request.contextPath}/assets/js/dataTables/dataTables.bootstrap.js"></script>
<style type="text/css">
/* placeholder 颜色 */
::-webkit-input-placeholder { /* WebKit browsers */
	color: #717171;
}

:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
	color: #717171;
}

::-moz-placeholder { /* Mozilla Firefox 19+ */
	color: #717171;
}

:-ms-input-placeholder { /* Internet Explorer 10+ */
	color: #717171;
}

.top-navbar .navbar-brand {
	background: #2C445A;
}

.top-navbar .navbar-brand:hover {
	background: #0F2A3F;
}
</style>
</head>
<body>
	<div id="wrapper">
		<nav class="navbar navbar-default top-navbar" role="navigation">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle" data-toggle="collapse"
					data-target=".sidebar-collapse">
					<span class="sr-only">Toggle navigation</span> <span
						class="icon-bar"></span> <span class="icon-bar"></span> <span
						class="icon-bar"></span>
				</button>
				<a class="navbar-brand waves-effect waves-dark" href="index.html"><strong>壁纸之家</strong>
				</a>
			</div>

			<ul class="nav navbar-top-links navbar-right">

				<li><a class="dropdown-button waves-effect waves-dark" href="#"
					data-activates="dropdown1"><i class="fa fa-user fa-fw"></i> <b
						id="name">欢迎您！</b>
				</a>
				</li>
			</ul>
		</nav>
		<!-- Dropdown Structure -->
		<ul id="dropdown1" class="dropdown-content">
			<li><a href="#"><i class="fa fa-gear fa-fw"></i> 设置</a></li>
			<li><a
				href="${pageContext.request.contextPath}/system/user/tologin"><i
					class="fa fa-sign-out fa-fw"></i>注销</a></li>
		</ul>

		<!--/. NAV TOP  -->

		<nav class="navbar-default navbar-side" role="navigation">
			<div class="sidebar-collapse">
				<ul class="nav" id="main-menu">

					<li><a class="waves-effect waves-dark"
						href="${pageContext.request.contextPath}/system/user/toindex2"><i
							class="fa fa-leaf"></i>首页</a></li>
					<li><a class="waves-effect waves-dark"><i
							class="fa fa-user"></i>用户管理<span class="fa arrow"></span>
					</a>
						<ul class="nav nav-second-level">
							<li><a
								href="${pageContext.request.contextPath}/system/user/tousertable">用户列表</a>
							</li>
							<li><a
								href="${pageContext.request.contextPath}/system/user/toadd">添加用户</a>
							</li>
							<li><a
								href="${pageContext.request.contextPath}/system/user/toupdateuser">修改用户</a>
							</li>
						</ul></li>
					<li class="active"><a
						class="active-menu waves-effect waves-dark"><i
							class="fa fa-picture-o"></i>壁纸管理<span class="fa arrow"></span>
					</a>
						<ul class="nav nav-second-level">
							<li><a
								href="${pageContext.request.contextPath}/system/user/topicturetable"
								class="active-menu waves-effect waves-dark">壁纸列表</a></li>

						</ul></li>

				</ul>

			</div>

		</nav>
		<!-- /. NAV SIDE  -->
		<div id="page-wrapper">
			<div class="header">
				<h1 class="page-header">全壁纸</h1>
				<ol class="breadcrumb">
					<li><a href="#">首页</a>
					</li>
					<li><a href="#">壁纸管理</a>
					</li>
					<li class="active">壁纸列表</li>
				</ol>

			</div>

			<div id="page-inner">

				<div class="row">
					<div class="col-md-12">
						<!-- Advanced Tables -->
						<form class="form-inline">
							<div class="form-group">
								<div class="input-group">
									<input type="text" class="form-control" id="checkname"
										placeholder="分享者查询">
								</div>
							</div>
							<button type="button" class="btn btn-primary" onclick=""
								style="margin-left: 30px;">查询</button>
						</form>
						<div class="card">

							<div class="card-content">
								<div class="table-responsive">

									<table class="table table-striped table-bordered table-hover">
										<thead>
											<tr>
												<th>壁纸ID</th>
												<th>预览</th>
												<th>分享者</th>
												<th>类别</th>
												<th>分享时间</th>
												<th>操作</th>
											</tr>
										</thead>
										<tbody id="table">

										</tbody>

									</table>


									<div class="btn-group" role="group" style="float: right;">

										<div class="btn-group" role="group">
											<button type="button" class="btn btn-default dropdown-toggle"
												data-toggle="dropdown" id="start">首页</button>
										</div>

										<button type="button" class="btn btn-default" id="prev">
											<<</button>
										<button type="button" class="btn btn-default" id="next">
											>></button>

										<div class="btn-group" role="group">
											<button type="button" class="btn btn-default dropdown-toggle"
												data-toggle="dropdown" id="end">未页</button>
										</div>
										<input type="hidden" id="prevpage" value=""> <input
											type="hidden" id="nextpage" value=""> <input
											type="hidden" id="startpage" value=""> <input
											type="hidden" id="endpage" value="">

									</div>


								</div>

							</div>
						</div>
						<!--End Advanced Tables -->
					</div>
				</div>
				<!-- /. ROW  -->
				<footer>
					<p>
						<small> Designed by <a href="#">WSG</a> The home of the
							wallpaper <a href="#" target="_blank">壁纸之家</a> - Worth having</small>
					</p>
				</footer>
			</div>
			<!-- /. PAGE INNER  -->
		</div>
		<!-- /. PAGE WRAPPER  -->
		<!-- /. WRAPPER  -->

		<script>
    $(function(){
     		look(1);
     		getUserById();
     	});
    	function look(page){
    	
    		$.ajax({
    			url:"${pageContext.request.contextPath}/system/news/getAllNews",
    			data:{"page":page},
    			type:"GET",
    			dataType:"json",
    			success:function(data){
    			
    			$("#prevpage").val(data.prevPage);
    			$("#nextpage").val(data.nextPage);
    			$("#startpage").val(1);
    			$("#endpage").val(data.pageCount);
    			
    			$("#table").empty();
    			for(var i = 0;i<data.datas.length;i++){
    			
  var dom ='<tr class="odd gradeX"><td>'+data.datas[i].id+'</td><td style="text-align: center;" ><img src="${pageContext.request.contextPath}/'+data.datas[i].urlpicture+'" style="width:100px;height:100px;"/></td><td>'+data.datas[i].user.name+'</td><td>'+data.datas[i].category.p_category+'</td><td>'+data.datas[i].createtime+'</td><td><a href="javascript:del('+data.datas[i].id+')">'+"删除"+'</a></td></tr>'; 
    			$("#table").append(dom);
    					
    				}	

   		
    			},
    			error:function(){
    				alert("error");
    			}
    		});
    	};
    	
    	$('#prev').on('click',function(){
			look($("#prevpage").val());
			  return;
			
		}); 

		$('#next').on('click',function(){
			   look($("#nextpage").val());
			   return;
		}); 
		
		$('#start').on('click',function(){
			look($("#startpage").val());
			   return;
		});
		$('#end').on('click',function(){
			look($("#endpage").val());
			   return;
		}); 
		
     function del(userid){
		$.get("${pageContext.request.contextPath}/system/user/delUser?userid=" + userid,function(data){
			if("success" == data.result){
				alert("删除成功");
				window.location.reload();
			}else{
				alert("删除失败");
			}
		});
	};
	
	function getUserById(){
    		$.ajax({
    			url:"${pageContext.request.contextPath}/system/user/getUserById",
    			type:"GET",
    			dataType:"json",
    			success:function(data){
    			var name=data.name;	
    			$("#name").append(name) ;	
							
    			},
    		});
    	
    };
    
    
    	
    function check(page){
   		 var names=encodeURI($("#checkname").val());	
  
    		$.ajax({
    			url:"${pageContext.request.contextPath}/system/user/checkname",
    			data:{"page":page,"name":names,},
    			type:"GET",
    			dataType:"json",
    			success:function(data){

    			$("#table").empty();
    			for(var i = 0;i<data.datas.length;i++){
  var dom ='<tr class="odd gradeX"><td>'+data.datas[i].userid+'</td><td>'+data.datas[i].username+'</td><td>'+data.datas[i].name+'</td><td>'+data.datas[i].password+'</td><td><a href="${pageContext.request.contextPath}/system/user/getUser?userid='+data.datas[i].userid+'">'+"修改 |"+'</a><a href="javascript:del('+data.datas[i].userid+')">'+"删除"+'</a></td></tr>'; 
    					$("#table").append(dom) ;
    				}	
   
   		
    			},
    			error:function(){
    				alert("error");
    			}
    		});
    	};
    
     

    </script>
		<!-- Custom Js -->
		<script
			src="${pageContext.request.contextPath}/assets/js/custom-scripts.js"></script>
</body>

</html>
